<template>
  <div>
    <h2>学生姓名:{{ name }}</h2>
    <h2>学生年龄：{{ age }}</h2>
    <button @click="sendStudnetName">把学生名给school组件</button>
  </div>
</template>

<script>
export default {
  name: "Student",
  data() {
    return {
      name: "刘虎",
      age: 20,
    };
  },
  methods: {
    sendStudnetName() {
      this.$bus.$emit("hello", this.name);
    },
  },
};
</script>

<style scoped>
div {
  background: gray;
  margin: 30px;
}
</style>